<?php
namespace app\admin\controller;

use think\Controller;
use think\Request;
/**
 * Created by PhpStorm.
 * User: liaohonglai
 * Date: 2017/10/26
 * Time: 11:56
 */
class Upload
{

    public function uploadImg(Request $request) {
        $_FILES;
        $isFile = $_FILES["courseimg"]["error"] > 0;
        $myimg = $request->file("courseimg");
        if (file_exists("upload/" . $_FILES["courseimg"]["name"]))
        {
            echo $_FILES["courseimg"]["name"] . " already exists. ";
        }
        else
        {
            //return json($_FILES["courseimg"]["tmp_name"]);
            move_uploaded_file($_FILES["courseimg"]["tmp_name"],
                "D:/upload/" . $_FILES["courseimg"]["name"]);
            echo "Stored in: " . "D:/upload/" . $_FILES["courseimg"]["name"];
        }
        return json([$_FILES, $myimg, ROOT_PATH, $isFile]);
    }

}